<template>
    <el-dialog
    title="新增模块"
    top="10vh"
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    :before-close="onCloseDialog"
    >
        <moduleForm type="0" isOpenEdit="false" :id="parentId" ref="fromEl" @submitSubmit="submitSubmit"></moduleForm>

        <span slot="footer" class="dialog-footer">
            <el-button size="small" @click="cancelShow">取 消</el-button>
            <el-button size="small" type="primary" @click="handleSubmit">提交保存</el-button>
        </span>

    </el-dialog>
</template>
<script>
import moduleForm from './moduleForm'
export default {
  props: ['parentId', 'addShow'],
  components: {
    moduleForm
  },
  computed: {
    dialogVisible: {
      get() {
        return this.addShow
      },
      set() {}
      },
    },
  data() {
    return {}
  },
  mounted(){},
  methods: {
    handleSubmit() {
      this.$refs.fromEl.handleSubmit();
    },
    submitSubmit(){
      this.dialogVisible = false;
      this.$emit('getModules',{ refresh: true, addShow: false})
    },
    cancelShow() {
      this.$confirm("确定取消修改？").then(_ => {
        this.$emit('getModules', {refresh: false, addShow: false})
      }).catch(_ => {});
    },
    onCloseDialog(done){
      this.$confirm('确认关闭？').then(_ => {
        this.$emit('getModules',{refresh: false, addShow: false})
      }).catch(_ => {});
    }
 }
}
</script>
